package com.tanhua.dubbo.api;

/**
 * @ClassName UserApiImpl
 * @Description TODO
 * @Author @O_o
 * @Date 2023/10/28 17:11
 * @Version 1.0
 */

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.dubbo.mappers.UserMapper;
import com.tanhua.model.domain.User;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * dubbo服务
 */
@DubboService
@Service
public class UserApiImpl implements UserApi {

    @Autowired
    private UserMapper userMapper;

    //根据手机号码查询用户
    public User findByMobile(String mobile) {
        QueryWrapper<User> qw = new QueryWrapper<>();
        qw.eq("mobile",mobile);
        return userMapper.selectOne(qw);
    }


    @Override
    public Long save(User user) {
        userMapper.insert(user);
        return user.getId();
    }
}
